#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <fstream>


using namespace std;

#include "binfile.h"
#include "timeelapsed.h"
#include "libn1.h"
#include "both.h"

Int8 n = 5;
Int8 nPre = n - 1;
Int64 fCount = (Int64)1 << (1 << n);

vector<bool> markF;
queue<Int32> mcbQ;

Int32 counter = 0;

queue<Int64> lpq;

inline void lpqpush(const Int64 f) {  
  if (!markF[f]) lpq.push(f);
  markF[f] = true;
}

inline void MarkLPClassBy(Int32 f) {
  lpqpush(f);
  while(!lpq.empty()) {
    f = lpq.front();
    lpq.pop(); 
    for(size_t j = 0; j < n; j++) {
      lpqpush(negbyvar(f, j, n));
      lpqpush(d1byvar(f, j, n));
      lpqpush(d2byvar(f, j, n));
      lpqpush(d3byvar(f, j, n));
      lpqpush(d4byvar(f, j, n));
      if (j != n - 1) lpqpush(swapvars(f, j, n));
    }
  }
}

int main() {  
  markF.resize((Int64)1 << (1 << n));
  MakeAddArrays(n);
  counter = 0;
  TimeElapsed circle1;
  int hc = 0;
  cout << "Calculating..." << endl;
  ofstream output("5lp.txt");
  for(Int64 f = 0; f < fCount; f++) if (!markF[f])  {
    MarkLPClassBy(f);      
    markF[f] = false;
    cout << counter << ' ' << f << endl;
    output << f << endl;
    counter++;      
  }
  output.close();
  cout << "circle1 " << counter << ' ' << circle1 << endl;
  
  
  return 0;
}
